package settings.Action;

/**
 * Represents the target of a {@link Action#VALIDATE}.
 * @author BDS
 */
public enum ValidateTarget
{
	ACTIVEPROCESS
	{
		/**
		 * Returns a string specific to the ValidateTarget.
		 * @return A string specific to the ValidateTarget.
		 */
		@Override
		public String toString()
		{
			return "Active process";
		}
	},
	ACTIVEWINDOW
	{
		/**
		 * Returns a string specific to the ValidateTarget.
		 * @return A string specific to the ValidateTarget.
		 */
		@Override
		public String toString()
		{
			return "Active window";
		}
	},
	WINDOW
	{
		/**
		 * Returns a string specific to the ValidateTarget.
		 * @return A string specific to the ValidateTarget.
		 */
		@Override
		public String toString()
		{
			return "Window";
		}
	},
	IMAGE
	{
		/**
		 * Returns a string specific to the ValidateTarget.
		 * @return A string specific to the ValidateTarget.
		 */
		@Override
		public String toString()
		{
			return "Image";
		}
	};
	
	/**
	 * Generates a ValidateTarget from the given name.
	 * @param name The ValidateTarget name.
	 * @return The ValidateTarget associated with the given ValidateTarget name; 
	 * {@link ValidateTarget#IMAGE} if not supported.
	 */
	public static ValidateTarget fromName(String name)
	{
		if (name != null) 
		{
			for (ValidateTarget validateTarget : ValidateTarget.values()) 
			{
				if (name.equalsIgnoreCase(validateTarget.toString())) 
				{
					return validateTarget;
				}
			}
		}

		return ValidateTarget.IMAGE;
	}
}
